// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'
import VueApollo from 'vue-apollo'
Vue.config.productionTip = false
//配置请求路径
const httpLink = new HttpLink({
  // You should use an absolute URL here
  uri: 'http://localhost:3000/api/demo1',
})
// 中间件添加请求头

//创建  Apollo链接

const apolloClient = new ApolloClient({
  link: httpLink,
  cache: new InMemoryCache()
})

// Install the vue plugin
Vue.use(VueApollo)
//可配置多个  路径
const apolloProvider = new VueApollo({
  defaultClient: apolloClient,
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  provide: apolloProvider.provide(),
  components: { App },
  template: '<App/>'
})
